<template>
  <el-container>

    <el-aside>
  <div>
    <el-input
        placeholder="输入名称"
        v-model="filterText">
    </el-input>
    <br>
    <el-button>重置</el-button>

    <el-tree
        :data="menusList"
        show-checkbox
        ref="tree"
        node-key="id"
        :props="defaultProps"
        default-expand-all
        :filter-node-method="filterNode">
    </el-tree>


  </div>
    </el-aside>
    <el-aside>
      <div>
        <span>987987987987987</span>
      </div>
    </el-aside>
  </el-container>
</template>

<script>
import {getmenuList} from "@/api/menu";

export default {
  name: "LeftMenus",

  watch: {
    filterText(val) {
      this.$refs.tree.filter(val);
    }
  },

  data() {
    return {
      // name:'',
      filterText: '',
      queryInfo:'',
      defaultProps: {
        children: 'children',
        label: 'name'
      },
      menusList: [],

      addForm:{
        name:'',
        describe:'',
        isPublic:'',
        path:'',
        component:'',
        isEnable:'',
        sortValue:'',
        icon:'',
        group:'',
        parentId:'',
      },

    }
  },
  methods: {

    filterNode(value, data) {
      if (!value) return true;
      return data.name.indexOf(value) !== -1;
    },


    viewmenus() {
      //选中前先取消上一选中结果
      // this.$refs.tree.setCheckedKeys([]);
      getmenuList(this.queryInfo).then(({data}) => {

        this.menusList = data.page;

      }).catch(err => {
        console.log(err)
      })
    },
  },

  mounted() {
    this.viewmenus()
  },
};
</script>


<style scoped>

</style>